<?php namespace App\Http\Controllers\Api\Admin;

use App\Http\Controllers\Controller;
use App\VisitLog;
use Illuminate\Http\Request;

class DataController extends Controller
{
    public function getNewData(Request $request){
        $lastTime = $request->get('last_time');

        $startTime = strtotime($lastTime);
        $endTime   = strtotime($lastTime) - 59;

        $theHourCount = VisitLog::whereBetween('created_at',[date('Y-m-d H:i:s',$endTime),date('Y-m-d H:i:s',$startTime)])->count();
        $data['time'] = date('Y-m-d H:i:s',$startTime);
        $data['num']  = $theHourCount;

        return response()->json(['level'=>'success','data'=>$data]);
    }
}